package com.example.backblog.controller.front.blog;

import com.example.backblog.controller.base.BaseController;
import com.example.backblog.dto.blog.CommentDto;
import com.example.backblog.entity.blog.Comment;
import com.example.backblog.repository.blog.CommentRepository;
import com.example.backblog.vo.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/comment")
public class CommentController extends BaseController<Comment, CommentDto, CommentRepository> {
    @Autowired
    @Override
    public void setBaseRepository(CommentRepository baseRepository) {
        this.baseRepository = baseRepository;
    }
    @GetMapping("/blogId")
    public ApiResult obtainByBlog(Long blogId){
        List<Comment> comments = this.baseRepository.findAllByBlogIdEquals(blogId);
        return ApiResult.success(comments);
    }
}
